//
//  AppDelegate.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/13.
//  Copyright © 2016年 light. All rights reserved.
//

#import "AppDelegate.h"
#import "RecommendHomePageViewController.h"
#import "FormulateHomePageViewController.h"
#import "CityHomePageViewController.h"
#import "MineHomePageViewController.h"
#import "AddHomePageViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//打开数据库并创建表
    [[DataBaseHandle shareDataBaseHandle] openFMDB];
    [[DataBaseHandle shareDataBaseHandle] createStoryTable];
 //  [[DataBaseHandle shareDataBaseHandle] dropStoryTable];


#pragma mark 创建5个主界面的UINavigationController
    //推荐界面的视图控制器
    RecommendHomePageViewController *recommendHPVC = [[RecommendHomePageViewController alloc] init];
    UINavigationController *recommendHPNa = [[UINavigationController alloc] initWithRootViewController:recommendHPVC];
    //创建推荐tabBar
    recommendHPNa.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"推荐" image:[[UIImage imageNamed:@"littleStarStar"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"recomm"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    //城市界面的视图控制器
    CityHomePageViewController *cityHPVC= [[CityHomePageViewController alloc] init];
    UINavigationController *cityHPNa = [[UINavigationController alloc] initWithRootViewController:cityHPVC];
    //创建城市tabBar
  cityHPNa.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"城市猎人" image:[[UIImage imageNamed:@"cityhunter2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"cityhunter1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    //加入界面视图控制器
  //  AddHomePageViewController *addHPVC = [[AddHomePageViewController alloc] init];
   // UINavigationController *addHPNa = [[UINavigationController alloc] initWithRootViewController:addHPVC];
   //创建加入tabBar
  //  addHPNa.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@""] imageWithRenderingMode:1] tag:100003];
    
    
    //制定界面视图控制器
    FormulateHomePageViewController *formulateHPVC = [[FormulateHomePageViewController alloc] init];
    UINavigationController *formulateHPNa = [[UINavigationController alloc] initWithRootViewController:formulateHPVC];
   //创建制定tabBar
    formulateHPNa.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"定制" image:[[UIImage imageNamed:@"dingzhi-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"dingzhi-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    //我的界面视图控制器
    MineHomePageViewController *mineHPVC = [[MineHomePageViewController alloc] init];
    UINavigationController *mineHPNa = [[UINavigationController alloc] initWithRootViewController:mineHPVC];
    
    //创建我的tabBar
    mineHPNa.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"wode-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"wode-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    self.window.rootViewController = tabBar;
 //   tabBar.viewControllers = @[recommendHPNa,cityHPNa,addHPNa,formulateHPNa,mineHPNa];
   //tabBar的选中颜色
     tabBar.viewControllers = @[recommendHPNa,cityHPNa,formulateHPNa,mineHPNa];
    tabBar.tabBar.tintColor = [UIColor colorWithRed:0 / 255.0 green:159 / 255.0 blue:168 / 255.0 alpha:1];
    tabBar.tabBar.tintColor = [UIColor whiteColor];
    //tabBar的背景颜色
    tabBar.tabBar.barTintColor = [UIColor colorWithRed:0 / 255.0 green:191 / 255.0 blue:202 / 255.0 alpha:1];

//    UIView *view = [[UIView alloc] init];
//    view.frame = CGRectMake(tabBar.tabBar.frame.size.width / 5 * 2, 0, tabBar.tabBar.frame.size.width / 5, tabBar.tabBar.frame.size.height);
//    view.backgroundColor = [UIColor colorWithRed:194 / 255.0 green:222 / 255.0 blue:72 / 255.0 alpha:1];
//     [tabBar.tabBar addSubview:view];
//    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(tabBar.tabBar.frame.size.width / 5 * 2, 0, tabBar.tabBar.frame.size.width / 5, tabBar.tabBar.frame.size.height)];
//    
//    imageV.image = [UIImage imageNamed:@"jiahao"];
//     [tabBar.tabBar addSubview:imageV];
//    
//    
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
//    [imageV addGestureRecognizer:tap];
//    imageV.userInteractionEnabled = YES;
//    
   
    
    
   
    // Override point for customization after application launch.
    return YES;
}


- (void)tapAction
{
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(100,100 , 150, 150)];
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(20, 20, 50, 50);
    

}



- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
